using System;

using EMan.BL.EntityEditing;
using EMan.BL.Properties;
using EMan.Interface.EnterpriseStructure.Departments;
using EMan.Interface.EntityEditing;

using TrueCode.Core.Aspects;
using TrueCode.Core.Diagnostics;

namespace EMan.BL.EnterpriseStructure
{
  [UsedImplicitly]
  public class DepartmentEditorPresenter : EntityEditorPresenter, IDepartmentEditorPresenter
  {
    private readonly DepartmentEditable _departmentEditable;
    private readonly IEntityProperty    _title;
    private readonly IEntityProperty    _description;

    public DepartmentEditorPresenter( [NotNull] DepartmentEditable departmentEditable, [NotNull] IDiagnostic diagnostic ) : base( diagnostic )
    {
      if( departmentEditable == null ) throw new ArgumentNullException( "departmentEditable" );
      _departmentEditable = departmentEditable;

      _title = new EntityProperty< string >( Resources.CreateDepartment_Name_Description,
                                          () => _departmentEditable.Title,
                                          v => _departmentEditable.Title = v );

      _description = new EntityProperty< string >( Resources.CreateDepartment_Description_Description,
                                                   () => _departmentEditable.Description, 
                                                   v => _departmentEditable.Description = v );
      OkCommand.CanExecute = true;
    }

    public IEntityProperty Title
    {
      get { return _title; }
    }

    public IEntityProperty Description
    {
      get { return _description; }
    }

    public override void Dispose(){}
  }
}